package likouJava;

public class 轮转数组 {
    public void rotate(int[] nums, int k) {
        int n = nums.length;
        k %= n;
        //创建一个中间数组过度
        int[] result = new int[n];
        for (int i = 0; i < n; i++) {
            result[(k + i) % n] = nums[i];
        }
        //拷贝给nums
        for (int i = 0; i < n; i++) {
            nums[i] = result[i];
        }
    }

}
